// 客户模糊查询
import React from 'react';
import { Select, Spin } from 'antd';
// import { connect } from 'dva';

const { Option } = Select;

// @connect(({ bigaccomanage: { bigwareList }, loading }) => ({
//   bigwareList,
//   loading: loading.effects['bigaccomanage/fetchBigwareList'],
// }))
class BigwareList extends React.Component {
  // constructor(props) {
  //   super(props);
  // }

  // // 获取大库列表
  // search = value => {
  //   const { dispatch } = this.props;
  //   if (value.trim().length) {
  //     dispatch({
  //       type: 'bigaccomanage/fetchBigwareList',
  //       payload: { accoName: value.trim() },
  //     });
  //   }
  // };
  search = value => {
    const { onSearch = () => {} } = this.props;
    onSearch(value);
  };

  render() {
    const { bigwareList = [], loading, getData = () => {} } = this.props;
    // console.log(loading);
    return (
      <Select
        placeholder="请输入关键字检索"
        {...this.props}
        showSearch
        optionFilterProp="children"
        showArrow={false}
        onSearch={this.search}
        onSelect={(value, options) => getData(value, options)}
        notFoundContent={loading ? <Spin size="small" /> : '暂无数据'}
      >
        {bigwareList.map(item => (
          <Option key={item.insAccoId || item.accuAccoId}>{item.insName || item.accoName}</Option>
        ))}
      </Select>
    );
  }
}
export default BigwareList;
